<?php
/**
 * 默认接口服务类
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */

class Api_Work extends PhalApi_Api {

	public function getRules() {
		return array(
			'listWork'=>array(
				'doctor_id'=>array('name'=>'DoctorId','require'=>true)
			),
			'getWork'=>array(
				'work_id'=>array('name'=>'WorkId','require'=>true)
			),
			'listDoctorOfWork'=>array(
				'event_id'=>array('name'=>'EventId','require'=>true),
				'lng'=>array('name'=>'Lng','require'=>true),
				'lat'=>array('name'=>'Lat','require'=>true),
			)
		);
	}

	/**
	 * 出诊信息列表
	 * @desc 出诊信息列表
	 * @return int code 操作码，0表示成功， 1错误
	 * @return object info 信息对象
	 * @return string msg 提示信息
	 */
	public function listWork() {
		$rs = array('code' => 0, 'msg' => '', 'info' => array());

		$domain = new Domain_Work();
		$info = $domain->listWork($this->doctor_id);

		if (empty($info)) {
			DI()->logger->debug('listWork()','');

			$rs['code'] =1;
			$rs['msg'] = T('没有出诊信息');
			return $rs;
		}

		$rs['info'] = $info;
		DI()->logger->debug('info of listWork()', $rs);

		return $rs;

	}
	/**
	 * 获取出诊信息详情
	 * @desc 获取出诊信息详情
	 * @return int code 操作码，0表示成功， 1错误
	 * @return object info 信息对象
	 * @return string msg 提示信息
	 */
	public function getWork() {
		$rs = array('code' => 0, 'msg' => '', 'info' => array());

		$domain = new Domain_Work();
		$info = $domain->getWork($this->work_id);

		if (empty($info)) {
			DI()->logger->debug('getWork()','');

			$rs['code'] = 1;
			$rs['msg'] = T('获取出诊信息详情失败');
			return $rs;
		}

		$rs['info'] = $info;
		DI()->logger->debug('info of getWork()', $rs);

		return $rs;

	}

	/**
	     * 获取出诊医生列表
	     * @desc 添加了医生和事件地点的距离
	     * @return int code 操作码，0表示成功， 1错误
	     * @return object info 信息对象
	     * @return string msg 提示信息
	     */
	public function listDoctorOfWork() {
	        $rs = array('code' => 0, 'msg' => '', 'info' =>array('a'=>1));

	        $domain = new Domain_Work();
	        $info = $domain->listDoctorOfWork($this->event_id,$this->lng,$this->lat);

	        if (empty($info)) {
	            DI()->logger->debug('listDoctorOfWork()','');

	            $rs['code'] = 1;
	            $rs['msg'] = T('没有出诊医生');
	            return $rs;
	        }

	        $rs['info'] = $info;
	        DI()->logger->debug('info of listDoctorOfWork()', $rs);

	        return $rs;

	    }
}